
package data;

import java.util.ArrayList;

/**
 * This class initialize a Job for the RCPSP.
 * <p>
 * A job is defined by :
 *  <MENU>
 *      a process time<BR>
 *      the different kinds of ressources it consumes<BR>
 *      amounts needed of each ressource<BR>
 *      jobs which have to be done only after itself<BR>
 *  </MENU>
 * <b><u>Notes</u> :</b>
 *  <MENU>
 *      A job consumes all amounts of all ressources needed during its processTime.<BR>
 *      All jobs which are created in order to be ordered together
 *          must have same kinds of ressources (with same order)<BR>
 *      (if a job A doesn't consume a ressource t1, the t1's amountRequestRess of A is 0...)<BR> 
 * </MENU>
 */
public class Job {
    
    private int processTime;    //Time of the job
    private ArrayList<Integer> amountRequestRess;   //Ressources needed (the length is fixed because 
                                                  //all jobs have to consume all kind of ressource (they can consume 0 of a ressource...))
    private ArrayList<Job> successors;      //jobs should be done only after itself
    
    /**
     * Initializes a new Job.
     * @param pi the process time of this job.
     */
    public Job( int pi ){
        
        this.processTime = pi;
        amountRequestRess = new ArrayList<>();
        successors = new ArrayList<>();
        
    }
    
    /**
     * Returns the time to end this job.
     * @return the time to end this job. 
     */
    public int getProcessTime() {
        return processTime;
    }    
    
    /**
     * Adds a ressource and amount needed for this job.
     * <p>
     * Note : A job consume all amounts of all ressources needed during it's processTime.
     * <p>
     * If a job A doesn't consume a ressource t1, the t1's amountRequestRess of A is 0...
     * 
     * @param amount the amount needed for this job.
     */
    public void addRessource( int amount ){
        
        amountRequestRess.add(amount);
    }
    
    /**
     * Adds a successor job for this job.
     * @param successor a job which must be done only after this job.
     */
    public void addSuccessor(Job successor){
        
        successors.add(successor);
        
    }
    
    /**
     * Returns all jobs successors of this job.
     * @return all jobs which must be done after this job. 
     */
    public ArrayList<Job> getSuccessors() {
        return successors;
    }
    
    /**
     * Returns all times of all requested (or not) ressources.
     * <p>
     * The order of ressource type is the natural order (0,1,2,...).
     * <p>
     * If a job A doesn't consume a ressource t1, the t1 amountRequestRess of A is 0...
     *
     * @return all times of all requested (or not) ressources.
     */
    public ArrayList<Integer> getAmountRequestRess() {
        return amountRequestRess;
    }
    
    
    
}
